library ykfalert;

import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

enum YKAlertPosition { UP, DOWN, CENTER }

class YKAlert {
  static toast(String msg, {YKAlertPosition position = YKAlertPosition.CENTER}) {
    if (msg == "") {
      return;
    }
    Alignment alignment = Alignment.center;
    switch (position) {
      case YKAlertPosition.UP:
        alignment = Alignment.topCenter;
        break;
      case YKAlertPosition.DOWN:
        alignment = Alignment.bottomCenter;
        break;
      case YKAlertPosition.CENTER:
        alignment = Alignment.center;
        break;
      default:
        break;
    }

    SmartDialog.showToast(msg, alignment: alignment);
  }

  static show(Widget widget, {YKAlertPosition position = YKAlertPosition.CENTER}) {
    Alignment alignment = Alignment.center;
    switch (position) {
      case YKAlertPosition.UP:
        alignment = Alignment.topCenter;
        break;
      case YKAlertPosition.DOWN:
        alignment = Alignment.bottomCenter;
        break;
      case YKAlertPosition.CENTER:
        alignment = Alignment.center;
        break;
      default:
        break;
    }
    SmartDialog.show(
        alignment: alignment,
        builder: (content) {
          return widget;
        });
  }
}
